home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2001 January / Game.EXE_01_2001.iso / demos / Blade of Darkness / data1.cab / Program_Executable_Files / Lib / Torchs.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-11-16  |  8.0 KB  |  188 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import Bladex
  5. import InitDataField
  6. import AuxFuncs
  7. import Actions
  8. import Reference
  9. OFF = 0
  10. ON = 1
  11. DEAD = 0
  12. ALIVE = 1
  13. tipos_antorcha = ('Antorcha', 'Antorchaenpared', 'Palangana')
  14.  
  15. class TorchObj:
  16.     pass
  17.  
  18.  
  19. def ExtingueGradual(torchobj, torchspot, torchfire, intensity_var, fire_var, fire_int, OnEndExtinctionFunc, OnEndExtinctionArgs):
  20.     if torchspot.Intensity > 0.0:
  21.         torchspot.Intensity = torchspot.Intensity - intensity_var
  22.     else:
  23.         torchspot.Intensity = 0
  24.     fire_int = fire_int + fire_var
  25.     torchfire.Intensity = fire_int
  26.     if torchfire.Intensity >= 30.0:
  27.         torchobj.LiveStatus = DEAD
  28.         torchobj.LightStatus = OFF
  29.         if OnEndExtinctionFunc:
  30.             apply(OnEndExtinctionFunc, OnEndExtinctionArgs)
  31.         
  32.         return None
  33.     
  34.     Bladex.AddScheduledFunc(Bladex.GetTime() + 0.1, ExtingueGradual, (torchobj, torchspot, torchfire, intensity_var, fire_var, fire_int, OnEndExtinctionFunc, OnEndExtinctionArgs))
  35.  
  36.  
  37. def ExtingueAntorcha(torch_name, OnEndExtinctionFunc = '', OnEndExtinctionArgs = ()):
  38.     torch = Bladex.GetEntity(torch_name)
  39.     torchspot = AuxFuncs.GetSpot(torch)
  40.     torchfire = AuxFuncs.GetFire(torch)
  41.     torchobj = torch.Data.torchobjdata
  42.     if torchspot.Intensity <= 0.0:
  43.         return None
  44.     
  45.     intensity_var = torchspot.Intensity / 20.0
  46.     fire_var = (30.0 - torchfire.Intensity) / 60.0
  47.     fire_int = torchfire.Intensity
  48.     Bladex.AddScheduledFunc(Bladex.GetTime() + 0.1, ExtingueGradual, (torchobj, torchspot, torchfire, intensity_var, fire_var, fire_int, OnEndExtinctionFunc, OnEndExtinctionArgs))
  49.     if Reference.EntitiesObjectData.has_key(torch_name):
  50.         del Reference.EntitiesObjectData[torch_name]
  51.     
  52.  
  53.  
  54. def EnciendeGradual(torchobj, torchspot, torchfire, intensity_var, fire_var, fire_int):
  55.     torchspot.Intensity = torchspot.Intensity + intensity_var
  56.     fire_int = fire_int - fire_var
  57.     torchfire.Intensity = fire_int
  58.     if torchspot.Intensity >= torchobj.LightIntensity:
  59.         torchobj.LightStatus = ON
  60.         return None
  61.     
  62.     Bladex.AddScheduledFunc(Bladex.GetTime() + 0.1, EnciendeGradual, (torchobj, torchspot, torchfire, intensity_var, fire_var, fire_int))
  63.  
  64.  
  65. def EnciendeAntorcha(torch_name):
  66.     torch = Bladex.GetEntity(torch_name)
  67.     torchspot = AuxFuncs.GetSpot(torch)
  68.     torchfire = AuxFuncs.GetFire(torch)
  69.     torchobj = torch.Data.torchobjdata
  70.     if torchobj.LightStatus == ON:
  71.         return None
  72.     
  73.     intensity_var = torchobj.LightIntensity / 20.0
  74.     fire_var = (10.0 - torchobj.FireIntensity) / 20.0
  75.     torchfire.Intensity = 10.0
  76.     fire_int = torchfire.Intensity
  77.     Bladex.AddScheduledFunc(Bladex.GetTime() + 0.1, EnciendeGradual, (torchobj, torchspot, torchfire, intensity_var, fire_var, fire_int))
  78.     Reference.EntitiesObjectData[torch_name] = Reference.DefaultObjectData['AntorchaFuego']
  79.  
  80.  
  81. def EnciendeEstaAntorcha(person_name, event_name):
  82.     pj = Bladex.GetEntity(person_name)
  83.     pj.DelAnmEventFunc(event_name)
  84.     torch = pj.Data.obj_used
  85.     torchobj = torch.Data.torchobjdata
  86.     objright = Bladex.GetEntity(pj.InvRight)
  87.     objrighttorch = objright.Data.torchobjdata
  88.     if objrighttorch.LightStatus == OFF and torchobj.LightStatus == ON:
  89.         EnciendeAntorcha(objright.Name)
  90.         if objrighttorch.Life > 0.0:
  91.             Bladex.AddScheduledFunc(Bladex.GetTime() + objrighttorch.Life, ExtingueAntorcha, (objright.Name,))
  92.         
  93.     else:
  94.         EnciendeAntorcha(torch.Name)
  95.         if torchobj.Life > 0.0:
  96.             Bladex.AddScheduledFunc(Bladex.GetTime() + torchobj.Life, ExtingueAntorcha, (torch.Name,))
  97.         
  98.  
  99.  
  100. def TorchUseFunc(torch_name, use_from):
  101.     torch = Bladex.GetEntity(torch_name)
  102.     pj = Bladex.GetEntity('Player1')
  103.     objright = Bladex.GetEntity(pj.InvRight)
  104.     if objright and torch.Kind in tipos_antorcha and objright.Kind in tipos_antorcha:
  105.         torchobj = torch.Data.torchobjdata
  106.         objrighttorch = objright.Data.torchobjdata
  107.         if objrighttorch.LightStatus == OFF and torchobj.LightStatus == OFF and objrighttorch.LightStatus == ON and torchobj.LightStatus == ON:
  108.             return None
  109.         
  110.         if torchobj.LiveStatus == DEAD or objrighttorch.LiveStatus == DEAD:
  111.             return None
  112.         
  113.         Actions.QuickTurnToFaceEntity('Player1', torch_name)
  114.         difalt = -(torch.Position[1] - (pj.Position[1] + pj.Dist2Floor))
  115.         chartype = Bladex.GetCharType(pj.CharType, pj.CharTypeExt)
  116.         if difalt <= chartype.MaxTake1:
  117.             pj.LaunchAnmType('fire_g')
  118.         elif difalt <= chartype.MaxTake2:
  119.             pj.LaunchAnmType('fire0')
  120.         elif difalt <= chartype.MaxTake3:
  121.             pj.LaunchAnmType('fire1')
  122.         elif difalt <= chartype.MaxTake4:
  123.             pj.LaunchAnmType('fire2')
  124.         elif difalt <= chartype.MaxTake5:
  125.             pj.LaunchAnmType('fire3')
  126.         else:
  127.             return None
  128.         if UseFunc:
  129.             UseFunc(torch.Name, objright.Name)
  130.         
  131.         pj.AddAnmEventFunc('SetAlightEvent', EnciendeEstaAntorcha)
  132.     
  133.  
  134.  
  135. def SetUsable(obj_name, light_int = 3.0, fire_int = 3.0, life = -1):
  136.     obj = Bladex.GetEntity(obj_name)
  137.     if obj.Kind not in tipos_antorcha:
  138.         return None
  139.     
  140.     torchobj = TorchObj()
  141.     torchobj.LightIntensity = light_int
  142.     torchobj.FireIntensity = fire_int
  143.     torchobj.Life = life
  144.     if AuxFuncs.GetSpot(obj).Intensity == 0.0:
  145.         torchobj.LightStatus = OFF
  146.         if Reference.EntitiesObjectData.has_key(obj_name):
  147.             del Reference.EntitiesObjectData[obj_name]
  148.         
  149.     else:
  150.         torchobj.LightStatus = ON
  151.         Reference.EntitiesObjectData[obj_name] = Reference.DefaultObjectData['AntorchaFuego']
  152.     if life == 0:
  153.         torchobj.LiveStatus = DEAD
  154.     else:
  155.         torchobj.LiveStatus = ALIVE
  156.     InitDataField.Initialise(obj)
  157.     obj.Data.torchobjdata = torchobj
  158.     if obj.Kind != 'Antorcha':
  159.         obj.UseFunc = TorchUseFunc
  160.     
  161.  
  162. UseFunc = None
  163.  
  164. def SaveData(filename):
  165.     import cPickle
  166.     import GameStateAux
  167.     funcfile = open(filename, 'wt')
  168.     p = cPickle.Pickler(funcfile)
  169.     d = (GameStateAux.SaveFunctionAux(UseFunc), tipos_antorcha)
  170.     p.dump(d)
  171.     funcfile.close()
  172.  
  173.  
  174. def LoadData(filename):
  175.     global UseFunc, tipos_antorcha
  176.     import cPickle
  177.     import GameStateAux
  178.     funcfile = open(filename, 'rt')
  179.     p = cPickle.Unpickler(funcfile)
  180.     d = p.load()
  181.     funcfile.close()
  182.     print d
  183.     UseFunc = GameStateAux.LoadFunctionAux(d[0])
  184.     tipos_antorcha = d[1]
  185.  
  186. import GameState
  187. GameState.ModulesToBeSaved.append(__import__(__name__))
  188.